<?php
#=================================================================================================================
#=================================================================================================================
#	Define all possible options in drop-down menu
#=================================================================================================================
#=================================================================================================================

 if( isset($_GET['edit_program']) or isset($_POST['edit_program']) or isset($_GET['view_program']) or 
 isset($_POST['view_program']) )
 {
	

	 $query_programe = mysqli_query($dbc, "SELECT `nume_program`,`cod`,`serie_autorizatie`,`nr_autorizatie_program`, `data_autorizatie_program`,
		`tip_program`,`SO_SPP`,`oferta_ucenicie`, `stare_program` FROM `furnizori_programe` WHERE `CUI_CF`='$var_cui_furnizor' AND `id_furnizori_programe`='$var_id_program'");

	if( $query_programe)
	{
			
		if($results_programe = mysqli_fetch_assoc($query_programe))
		{

				$form_for_table = array(
				#----------------------------------------------------------------------
				#						Tabel										  |
				#----------------------------------------------------------------------
			  
		array('field_type' 			=> 'text',
			  'field_display_name' 	=> 'Nume program',
			  'post_name' 			=> 'nume_program',
			  'id'					=> 'corNcName',
			  'current_value'		 => $results_programe['nume_program'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100),
			  
		array('field_type' 			=> 'text',
			  'field_display_name' 	=> 'Cod COR/Nomenclator',
			  'id'					=> 'corNcCode',
			  'post_name' 			=> 'cod',
			  'current_value'		 => $results_programe['cod'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100),										
						
		array('field_type' 			=> 'text',
			  'field_display_name' 	=> 'Serie autorizatie',
			  'post_name' 			 => 'serie_autorizatie',
			  'current_value'		 => $results_programe['serie_autorizatie'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100),
			  
		array('field_type' 			=> 'text',
			  'field_display_name' 	=> 'Nr. autorizatie program',
			  'post_name' 			 => 'nr_autorizatie_program',
			  'current_value'		 => $results_programe['nr_autorizatie_program'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100),
			  
		array('field_type' 			=> 'text',
			  'field_display_name' 	=> 'Data autorizatie program',
			  'post_name' 			 => 'data_autorizatie_program',
			  'placeholder'          => 'AAAA-LL-ZZ',
			  'title'				=> 'An-Luna-Zi',
			  'validation_function'   => 'dateLTEToday',
			  'regex'				=> '/^[1-2][0-9]{3}-(0[1-9]|10|11|12)-(0[1-9]|[1-2][0-9]|3[0-1])$/',
			  'errors' 				=> array(
												'empty_field_or_no_selection_error' => 'Introduceti o data de autorizatie a programului<br />',
												'no_regex_pattern_found_error' => 'Introduceti o data valida de autorizatie a programului<br />' ),
			  'current_value'		 => $results_programe['data_autorizatie_program'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100),
		
		array('field_type' 			=> 'drop_down_list',
			  'field_display_name' 	=> 'Tip program',
			  'post_name' 			 => 'tip_program',
			  'current_value'		 => $results_programe['tip_program'],
			  'field_size' 			=> 40,
			  'max_length' 			=> 100,
			  'initial_values'  		=> array('opt1' => 'Initiere',
											   'opt2' => 'Perfectionare',
											   'opt3' => 'Specializare',
											   'opt4' => 'Calificare'						  
											   )
				),
			 
		array('field_type' 			=> 'drop_down_list',
			  'field_display_name' 	=> 'SO SPP',
			  'post_name' 			=> 'SO_SPP',
			  'current_value'		 => $results_programe['SO_SPP'],
			  'field_size' 			=> 40,
			  'initial_values'  		=> array('opt1' => 'SO',
											   'opt2' => 'SPP',
											   'opt3' => 'Nu'					  
											   ),
			  'max_length' 			=> 100),										
			  
		array('field_type' 			=> 'drop_down_list',
			  'field_display_name' 	=> 'Oferta ucenicie',
			  'post_name' 			=> 'oferta_ucenicie',
			  'field_size' 			=> 40,
			  'current_value'		 => $results_programe['oferta_ucenicie'],
			  'initial_values'  		=> array('opt1' => 'Da',
											   'opt2' => 'Nu'					  
											   ),
			  'max_length' 			=> 100)
			  
			);	
		}
	}
}	 
 else
 {
		$form_for_table = array(
		#----------------------------------------------------------------------
		#						Tabel										  |
		#----------------------------------------------------------------------
				  
			array('field_type' 			=> 'text',
				  'field_display_name' 	=> 'Denumire COR/Nomenclator',
				  'post_name' 			=> 'nume_program',
				  'id'					=> 'corNcName',
				  'placeholder'			=> 'Ex. Electrician',
				  'field_size' 			=> 40,
				  'max_length' 			=> 100),
				  
		
			array('field_type' 			=> 'text',
				  'field_display_name' 	=> 'Cod COR/Nomenclator',
				  'post_name' 			=> 'cod',
				  'placeholder' 			 => 'Ex. 71411',
				  'id'					=> 'corNcCode',
				  'field_size' 			=> 40,
				  'max_length' 			=> 100),										
							
			array('field_type' 			=> 'text',
				  'field_display_name' 	=> 'Serie autorizatie',
				  'post_name' 			 => 'serie_autorizatie',
				  'placeholder' 			 => 'Ex. VL',
				  'regex'				 => '/^[\w ]+$/',
				  'field_size' 			=> 40,
				  'max_length' 			=> 100),
				  
			array('field_type' 			=> 'text',
				  'field_display_name' 	=> 'Nr. autorizatie program',
				  'post_name' 			 => 'nr_autorizatie_program',
				  'placeholder' 			 => 'Ex. 15',
				  'regex'				 => '/^[\d]{1,11}$/',
				  'field_size' 			=> 40,
				  'max_length' 			=> 100),
				  
			array('field_type' 			=> 'text',
				  'field_display_name' 	=> 'Data autorizatie program',
				  'post_name' 			 => 'data_autorizatie_program',
				  'placeholder'          => 'AAAA-LL-ZZ',
				  'title'				=> 'An-Luna-Zi',
				  'validation_function'   => 'dateLTEToday',
				  'regex'				=> '/^[1-2][0-9]{3}-(0[1-9]|10|11|12)-(0[1-9]|[1-2][0-9]|3[0-1])$/',
				  'errors' 				=> array(
												'empty_field_or_no_selection_error' => 'Introduceti o data de autorizatie a programului<br />',
												'no_regex_pattern_found_error' => 'Introduceti o data valida de autorizatie a programului<br />' ),
				  'field_size' 			=> 40,
				  'max_length' 			=> 100),
			
			array('field_type' 			=> 'drop_down_list',
				  'field_display_name' 	=> 'Tip program',
				  'post_name' 			 => 'tip_program',
				  'field_size' 			=> 40,
				  'max_length' 			=> 100,
				  'current_value'		 => 'opt1',
				  'initial_values'  		=> array(
												   'opt1' => 'Initiere',
												   'opt2' => 'Perfectionare',
												   'opt3' => 'Specializare',
												   'opt4' => 'Calificare'
												   )
					),
				 
			array('field_type' 			=> 'drop_down_list',
				  'field_display_name' 	=> 'SO SPP',
				  'post_name' 			 => 'SO_SPP',
				  'field_size' 			=> 40,
				  'initial_values'  		=> array('opt1' => 'SO',
												   'opt2' => 'SPP',
												   'opt3' => 'Nu'					  
												   ),
				  'max_length' 			=> 100),										
				  
			array('field_type' 			=> 'drop_down_list',
				  'field_display_name' 	=> 'Oferta ucenicie',
				  'post_name' 			=> 'oferta_ucenicie',
				  'field_size' 			=> 40,
				  'initial_values'  		=> array('opt1' => 'Da',
												   'opt2' => 'Nu'					  
												   ),
				  'max_length' 			=> 100)
			);	
 }

?>